
/* **********************************************************************
版本: 2022.3.62f1
作者: wzz
日期: 2025-8-1
描述: 不要忘记添加描述哦~.~！
***********************************************************************/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class LogReceive : MonoBehaviour
{

    public static Queue<string> LogMessages = new Queue<string>();



    void Start()
    {
        LogMessages.Clear();
        EventMgr._NetShowLog += AddLog;
    }

    private void OnDestroy()
    {
        EventMgr._NetShowLog -= AddLog;
    }

    private void Update()
    {
        if (LogMessages.Count > 0)
        { 
            lock (LogMessages)
            {
                while (LogMessages.Count > 0)
                {
                    TouchSocketView.Instance.AddLog(LogMessages.Dequeue());
                }
            }
        }
    }

    void AddLog(string message)
    {
        lock (LogMessages) {
            LogMessages.Enqueue(message);
        }
    }
}

